﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RazorTs.TemplateAxios
{
    public class TemplateMethod
    {

        public static string Template = @"import service from './config'
                                                import link from './link' 
                                                import* as common from './commonArgument'
                                                let ApiUrl = link.OAServiceX.APIService  
                                                  @foreach (var item in Model){
                                                        <text>
                                                          @item.Describes ;
                                                          export const @item.MethodName = async (@item.ParameterString)=>{
                                                            let responseData: any = await service({
                                                                url: ApiUrl + '@item.ApiUrl',
                                                                method: '@item.RequestMethod',
                                                                @if(item.IsParams){
                                                                    <text> params: @item.Params</text>
                                                                }
                                                                @if(item.IsData){
                                                                    <text>  data: @item.Data</text>
                                                                }
                                                            })
                                                            let responseDataReturn: @item.ReturnValue = responseData
                                                            return responseDataReturn
                                                        }</text>
                                                    }
";





        public static string TemplateTwo = @"
import service from '.././config'
import link from '.././link'
import * as common from '.././commonArgument'
let ApiUrl = link.OAServiceX.APIService
@foreach (var item in Model){
    if(!string.IsNullOrEmpty(@item.Describes)){<text>@item.Describes</text>}else{}
<text></text>
<text>export const @item.MethodName = async (@item.ParameterString) => {</text>
  <text>let responseData: any = await service({</text>
    <text>url: ApiUrl + '@item.ApiUrl',</text>
    <text>method: '@item.RequestMethod',</text>
if(!item.IsNullParam){
         if(item.IsParams){
    <text>params: @item.Params</text>
         }
         if(item.IsData){
    <text>data: @item.Data</text>
         }
}
  <text>})</text>
  <text>let responseDataReturn: @item.ReturnValue = responseData</text>
  <text>return responseDataReturn</text>
<text>}</text>
}
";


    }
}
